<?php

/*
 * This file is part of ibrand/distribution-backend.
 *
 * (c) iBrand <https://www.ibrand.cc>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace iBrand\Shop\Backend\Seeds;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class ShopBackendTablesSeeder extends Seeder
{
	/**
	 * Run the database seeds.
	 */
	public function run()
	{
		$lastOrder = DB::table(config('admin.database.menu_table'))->max('order');

		/**
		 * 仓库管理：
		 *
		 * 1、采购管理：采购单、采购退货单
		 * 2、库存管理：库存查询、库存盘点
		 * 3、商品管理：商品列表、品牌管理
		 */
		$store_parent = DB::table(config('admin.database.menu_table'))->insertGetId([
			'parent_id'  => 0,
			'order'      => $lastOrder++,
			'title'      => '仓库管理',
			'icon'       => 'iconfont icon-mendianguanli',
			'blank'      => 1,
			'uri'        => 'shop/list/store',
			'created_at' => date('Y-m-d H:i:s', time()),
			'updated_at' => date('Y-m-d H:i:s', time()),
		]);

		$purchase_manager = DB::table(config('admin.database.menu_table'))->insertGetId([
			'parent_id'  => $store_parent,
			'order'      => $lastOrder++,
			'title'      => '采购管理',
			'icon'       => 'iconfont icon-mendianguanli',
			'blank'      => 1,
			'uri'        => '',
			'created_at' => date('Y-m-d H:i:s', time()),
			'updated_at' => date('Y-m-d H:i:s', time()),
		]);
		DB::table(config('admin.database.menu_table'))->insertGetId([
			'parent_id'  => $purchase_manager,
			'order'      => $lastOrder++,
			'title'      => '采购单',
			'icon'       => 'iconfont icon-mendianguanli',
			'blank'      => 1,
			'uri'        => '',
			'created_at' => date('Y-m-d H:i:s', time()),
			'updated_at' => date('Y-m-d H:i:s', time()),
		]);
		DB::table(config('admin.database.menu_table'))->insertGetId([
			'parent_id'  => $purchase_manager,
			'order'      => $lastOrder++,
			'title'      => '采购退货单',
			'icon'       => 'iconfont icon-mendianguanli',
			'blank'      => 1,
			'uri'        => '',
			'created_at' => date('Y-m-d H:i:s', time()),
			'updated_at' => date('Y-m-d H:i:s', time()),
		]);

		$store_manager = DB::table(config('admin.database.menu_table'))->insertGetId([
			'parent_id'  => $store_parent,
			'order'      => $lastOrder++,
			'title'      => '库存管理',
			'icon'       => 'iconfont icon-mendianguanli',
			'blank'      => 1,
			'uri'        => '',
			'created_at' => date('Y-m-d H:i:s', time()),
			'updated_at' => date('Y-m-d H:i:s', time()),
		]);
		DB::table(config('admin.database.menu_table'))->insertGetId([
			'parent_id'  => $store_manager,
			'order'      => $lastOrder++,
			'title'      => '库存查询',
			'icon'       => 'iconfont icon-mendianguanli',
			'blank'      => 1,
			'uri'        => '',
			'created_at' => date('Y-m-d H:i:s', time()),
			'updated_at' => date('Y-m-d H:i:s', time()),
		]);
		DB::table(config('admin.database.menu_table'))->insertGetId([
			'parent_id'  => $store_manager,
			'order'      => $lastOrder++,
			'title'      => '库存盘点',
			'icon'       => 'iconfont icon-mendianguanli',
			'blank'      => 1,
			'uri'        => '',
			'created_at' => date('Y-m-d H:i:s', time()),
			'updated_at' => date('Y-m-d H:i:s', time()),
		]);

		$goods_manager = DB::table(config('admin.database.menu_table'))->insertGetId([
			'parent_id'  => $store_parent,
			'order'      => $lastOrder++,
			'title'      => '商品管理',
			'icon'       => 'iconfont icon-mendianguanli',
			'blank'      => 1,
			'uri'        => '',
			'created_at' => date('Y-m-d H:i:s', time()),
			'updated_at' => date('Y-m-d H:i:s', time()),
		]);

		DB::table(config('admin.database.menu_table'))->insertGetId([
			'parent_id'  => $goods_manager,
			'order'      => $lastOrder++,
			'title'      => '商品列表',
			'icon'       => 'iconfont icon-mendianguanli',
			'blank'      => 1,
			'uri'        => '',
			'created_at' => date('Y-m-d H:i:s', time()),
			'updated_at' => date('Y-m-d H:i:s', time()),
		]);

		DB::table(config('admin.database.menu_table'))->insertGetId([
			'parent_id'  => $goods_manager,
			'order'      => $lastOrder++,
			'title'      => '品牌管理',
			'icon'       => 'iconfont icon-mendianguanli',
			'blank'      => 1,
			'uri'        => '',
			'created_at' => date('Y-m-d H:i:s', time()),
			'updated_at' => date('Y-m-d H:i:s', time()),
		]);
	}
}
